package com.china.school.editor;

import java.beans.PropertyEditorSupport;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class MyDatePropertyEditor extends PropertyEditorSupport {
    private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    @Override
    public void setAsText(String text) throws IllegalArgumentException {
        try {
            //解析值
            Date parse = sdf.parse(text);
            //设置值
            setValue(parse);

        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
}
